const { Controller } = require('egg')

class NspController extends Controller {
  async exchange() {
    const { app, ctx } = this
    const users = app.io.of('/echart')
    users.emit('user_get', {
      message: 'user_get',
      data: [
        { type: '5G', number: 10000 },
        { type: '4G', number: 5000 },
        { type: '3G', number: 3000 },
      ],
    })
  }

  async ping() {
    const message = this.ctx.args[0]
    // await ctx.socket.emit('sendData', 'this is a response')
    await ctx.socket.emit('user_send', 'this is a response')
  }
}

module.exports = NspController
